package uilayer;

import javax.swing.JPanel;

import java.awt.GridBagLayout;

import javax.swing.JLabel;

import java.awt.GridBagConstraints;

import javax.swing.JTextField;

import java.awt.Insets;

import javax.swing.JButton;

import controllayer.CtrSale;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class DeleteSale extends JPanel {
	private JTextField textField;
	
	private CtrSale ctrSale;

	/**
	 * Create the panel.
	 */
	public DeleteSale() {
		ctrSale = new CtrSale();
		
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JLabel lblSaleId = new JLabel("Salg ID");
		GridBagConstraints gbc_lblSaleId = new GridBagConstraints();
		gbc_lblSaleId.insets = new Insets(0, 0, 5, 5);
		gbc_lblSaleId.gridx = 1;
		gbc_lblSaleId.gridy = 1;
		add(lblSaleId, gbc_lblSaleId);
		
		textField = new JTextField();
		GridBagConstraints gbc_textField = new GridBagConstraints();
		gbc_textField.insets = new Insets(0, 0, 5, 5);
		gbc_textField.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField.gridx = 3;
		gbc_textField.gridy = 1;
		add(textField, gbc_textField);
		textField.setColumns(10);
		
		JButton btnSlet = new JButton("Slet");
		btnSlet.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				ctrSale.deleteSale(Integer.parseInt(textField.getText()));
			}
		});
		GridBagConstraints gbc_btnSlet = new GridBagConstraints();
		gbc_btnSlet.gridx = 5;
		gbc_btnSlet.gridy = 2;
		add(btnSlet, gbc_btnSlet);

	}

}
